import Vue from 'vue'
import LoadComponent from '@/components/loading.vue'

const Loading = {}

Loading.install = (Vue) => {
  const LoadConstructor = Vue.extend(LoadComponent)

  const instance = new LoadConstructor()

  instance.$mount(document.createElement('div'))

  document.body.appendChild(instance.$el)

  Vue.prototype.$loading = (status, msg = null) => {
    instance.show = status;
    instance.message = msg;
  }
}

export default Loading